
local mysql = require("resty.mysql")
local ssdb = require("resty.ssdb")
ssdb.add_commands("qpush")    ---增加qpush命令
local L = require('coevent')

local _M = {
    _VERSION = '0.1'
}
function _M._mysql_new(self,tb)
    local mysql_db = mysql:new()      --mysql
    mysql_db:set_timeout(tb.mysql_timeout) 
    local ok_mysql, mysql_err, errno, sqlstate = mysql_db:connect({
        host = tb.mysql_host,
        port = tb.mysql_port,
        database = tb.mysql_db,
        user = tb.mysql_user,
        password = tb.msyql_pass})
    if not ok_mysql then
        return nil,mysql_err
    end
    return mysql_db
end

function _M._ssdb_new(self,tb)
    local ssdb_db = ssdb:new()      --ssdb
    ssdb_db:set_timeout(tb.ssdb_timeout)
    local ok_ssdb, ssdb_err = ssdb_db:connect(tb.ssdb_host, tb.ssdb_port)
    if not ok_ssdb then
        return nil,ssdb_err
    end
    return ssdb_db
end

return _M

